package org.dftproject.genesis.ui.presentation.stackcontrol;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

public class StackFooterFigure extends Figure {
	
	//private final Label label;
	
	public StackFooterFigure() {
		/*ToolbarLayout layout = new ToolbarLayout();
		setLayoutManager(layout);
		
		setBorder(new MarginBorder(5, 7, 5, 7));
		
		label = new Label();
		label.setLabelAlignment(PositionConstants.LEFT);
		label.setIcon(SharedImages.getDefault().getImage(SharedImages.IMG_NULL));
		label.setIconTextGap(5);
		add(label);*/
	}
	
	@Override
	public Dimension getPreferredSize(int wHint, int hHint) {
		return new Dimension(Math.max(0, wHint), 1);
	}
	
	public void setText(String text) {
		//label.setText(text);
	}
	
	public void setIcon(Image icon) {
		//label.setIcon(icon);
	}
	
	@Override
	public void paintFigure(Graphics graphics) {
		drawButton(graphics);
		super.paintFigure(graphics);
	}

	private final Color selectedTopTop = new Color(null, 255, 255, 255);
	private final Color selectedTopBottom = new Color(null, 234, 244, 255);
	private final Color selectedBottomTop = new Color(null, 196, 225, 255);
	private final Color selectedBottomBottom = new Color(null, 234, 244, 255);

	public void drawButton(Graphics graphics) {
		graphics.pushState();
		Rectangle bounds = getBounds();
		/*Rectangle innerBounds = bounds.getCropped(new Insets(0, 1, 0, 1));
		
		graphics.setForegroundColor(selectedTopTop);
		graphics.setBackgroundColor(selectedTopBottom);
		graphics.fillGradient(innerBounds.getResized(0, -innerBounds.height / 2), true);

		graphics.setForegroundColor(selectedBottomTop);
		graphics.setBackgroundColor(selectedBottomBottom);
		graphics.fillGradient(innerBounds.getResized(0, -innerBounds.height / 2).getTranslated(0, innerBounds.height / 2), true);
				
		graphics.setAntialias(SWT.ON);
		graphics.setForegroundColor(ColorConstants.white);
		graphics.setLineWidth(2);
		graphics.drawRectangle(bounds.getCropped(new Insets(1)));*/
		graphics.setForegroundColor(new Color(null, 0x55, 0x55, 0x55));
		graphics.setLineWidth(1);
		graphics.drawRectangle(bounds.getResized(0, -1));
		graphics.setAntialias(SWT.OFF);
		
		graphics.popState();
	}

}
